//var taskId = null;
var objs = {
	responseCheckWin: $("#responseCheckWin"),
	responseCheckForm: $("#responseCheckForm"),
	checkIdInput: $("#checkIdInput"),
	taskIdInput: $("#taskIdInput")
};

$(function(){
	$.parser.parse();
	
	objs.responseCheckWin.xwindow('center');
//	var currTaksId = $("#taksIdmain").val();
//	if(currTaksId!='null'&&currTaksId!=''){
//		taskId = currTaksId;
//	}
	objs.taskIdInput.val(taskId);
	loadResponseCheck();
});

// 加载认证设置数据
function loadResponseCheck() {
	$.get(
		baseUrl + '/apiManager/responseCheckAction!findOne.action',
		{
			'dto.apiResponseCheck.taskId': taskId,
			'dto.apiResponseCheck.authType': authType
		}, function(data, status, xhr){
			if(status == 'success'){
				objs.responseCheckForm.xdeserialize(data);
//				if(data && data.apiResponseCheck){
//					objs.globalAuthForm.xdeserialize(data);
//				}
			}
		}, 'json'
	);
}

// 提交保存
function save() {
	var valid = objs.responseCheckForm.xform('validate');
	if (!valid) {
		return;
	}
	
	var url = baseUrl + '/apiManager/responseCheckAction!saveOrUpdate.action';
	var data = objs.responseCheckForm.xserialize();
	var msg = objs.checkIdInput.val() ? '修改成功' : '保存成功';
	$.post(url,data,function(res) {
		if ('success' == res) {
			objs.responseCheckWin.xwindow('close');
			$.xnotify(msg, {type: 'success'});
		} else {
			$.xnotify('系统错误！', {type: 'warning'});
		}
	}, 'text');
}

// 取消关闭弹窗
function closeWin() {
	objs.responseCheckWin.xwindow('close');
}